﻿#pragma once

#include "MirImageControl.h"
#include "MirLabel.h"
#include "MirButton.h"
#include "MirTextBox.h"
#include "MirControl.h"
#include <string>
#include <cctype>
#include <any>

using namespace Client::MirGraphics;
using namespace Client::MirSounds;

namespace Client::MirControls
{
    class MirAmountBox final : public MirImageControl
    {
    public:
        MirLabel *TitleLabel, *TextLabel;
        MirButton *OKButton, *CancelButton, *CloseButton;
        MirTextBox *InputTextBox;
        MirControl *ItemImage;
        int ImageIndex = 0;
        unsigned int Amount = 0, MinAmount = 0, MaxAmount = 0;

        virtual ~MirAmountBox()
        {
            delete TitleLabel;
            delete TextLabel;
            delete OKButton;
            delete CancelButton;
            delete CloseButton;
            delete InputTextBox;
            delete ItemImage;
        }

        MirAmountBox(const std::string &title, int image, unsigned int max, unsigned int min = 0, unsigned int defaultAmount = 0);
        MirAmountBox(const std::string &title, int image, const std::string &message);

    private:
        void TextBox_TextChanged(std::any sender, EventArgs *e);

        void MirInputBox_KeyPress(std::any sender, KeyPressEventArgs *e);

        void DrawItem();

    public:
        void Show() override;
        void OnKeyDown(KeyEventArgs *e) override;
        void OnKeyUp(KeyEventArgs *e) override;
        void OnKeyPress(KeyPressEventArgs *e) override;

        #pragma region Disposable

    protected:
        void Dispose(bool disposing) override;

        #pragma endregion
    };
}
